package com.hk.core.sharding;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @author Kevin
 * @date 2024-07-03 17:03:20
 */
class HintTokenProviders implements HintTokenProvider {

    private final List<HintTokenProvider> providers = new ArrayList<>();

    public void addProvider(List<HintTokenProvider> providers) {
        this.providers.addAll(providers);
    }

    @Override
    public HintToken get() {
        for (HintTokenProvider provider : this.providers) {
            HintToken hintToken = provider.get();
            if (Objects.nonNull(hintToken)) {
                return hintToken;
            }
        }
        return null;
    }
}
